# 匹配多个字符
import re

# ?:表示匹配前面的字符出现0次或者1次
# print(re.search("faceb?ook","faceook"))  #<re.Match object; span=(0, 7), match='faceook'>   0次的情况
# print(re.search("faceb?ook","facebook")) # <re.Match object; span=(0, 8), match='facebook'> 1次的情况
# print(re.search("faceb?ook","facebbbbbook"))  # None  若? 前面的字符出现多次,匹配的是None

# +:表示匹配前面的字符出现1次或者多次
# print(re.search("faceb+ook","facebook"))   # <re.Match object; span=(0, 8), match='facebook'>
# print(re.search("faceb+ook","facebbbbbook"))   #<re.Match object; span=(0, 12), match='facebbbbbook'>


# *:表示匹配前面的字符出现0次或者多次
# print(re.search("faceb*ook","faceook"))  # <re.Match object; span=(0, 7), match='faceook'>
# print(re.search("faceb*ook","facebook")) # <re.Match object; span=(0, 8), match='facebook'>
# print(re.search("faceb*ook","facebbbbook"))  #<re.Match object; span=(0, 11), match='facebbbbook'>
  
# {n}: 表示前面的字符出现n次
# print(re.search("faceb{3}ook","facebook"))  # None
# print(re.search("faceb{3}ook","facebbbbbook"))  # None
# print(re.search("faceb{3}ook","facebbbook")) # <re.Match object; span=(0, 10), match='facebbbook'>

# {n,m}: 表示前面的字符出现n-m次
# print(re.search("faceb{3,6}ook","facebbbbook"))  # <re.Match object; span=(0, 11), match='facebbbbook'>

# {n,}: 表示前面的字符至少出现n次
# print(re.search("faceb{3,}ook","facebbook"))  # None
# print(re.search("faceb{3,}ook","facebbbook")) # <re.Match object; span=(0, 10), match='facebbbook'>
# print(re.search("faceb{3,}ook","facebbbbook"))# <re.Match object; span=(0, 10), match='facebbbbook'>

# {,n}:表示前面的字符最多出现n次
print(re.search("faceb{,3}ook","facebbbbbook"))  #None
print(re.search("faceb{,3}ook","facebbook"))  # <re.Match object; span=(0, 9), match='facebbook'>


